package com.gzhryc.shared_device.oem.code.place.dao.db;

import com.gzhryc.common.DateTools;
import com.gzhryc.common.StringTools;
import com.gzhryc.jdbc.annotaion.*;
import com.gzhryc.shared_device.base.models.IPlace;
import com.gzhryc.shared_device.oem.code.place.dao.enums.PlacePhysicalStoreEnum;
import com.gzhryc.shared_device.oem.code.user.dao.db.User;

import java.util.Date;

/**
 * 实体店信息
 * @version 2022-11-08
 */
@Table(name="place_physical_store")
public class PlacePhysicalStore implements IPlace {

    @Id(autoIncrement = 100)
    @Column
    protected Long id;

    @Index(name = "user_id")
    @Column(name = "user_id", notNull = true, note = "代理ID")
    protected Long userId;

    @Column(notNull = true, length = 64, note = "实体店名称")
    protected String name;

    @Column(name = "type_codes", length = 255, note = "实体店类型")
    protected String typeCodes;

    @Column(name = "type_names", length = 255, note = "实体店类型名称")
    protected String typeNames;

    @Column(name = "thumbnail_img", length = 255, note = "缩略图")
    protected String thumbnailImg;

    @Column(note = "省")
    protected String province;

    @Column(note = "城市")
    protected String city;

    @Column(name = "city_area", note = "城区")
    protected String cityArea;

    @Column(name = "area_code", length = 128, note = "地区ID，以逗号分隔")
    protected String areaCode;

    @Column(length = 64)
    protected String address; // 详细地址

    @Column(name="route_info",length = 255,note = "路线信息")
    protected String routeInfo;

    @Column(note = "经度", length = 10, decimalLen = 6)
    protected Double longitude;

    @Column(note = "纬度", length = 10, decimalLen = 6)
    protected Double latitude;

    @Column(name = "open_time", note = "开门时间")
    protected Integer openTime;

    @Column(name = "close_time", note = "关门时间")
    protected Integer closeTime;

    @Column(name = "contact_phone",length = 16, note = "联系电话")
    protected String contactPhone;

    @Column(notNull = true, defVal = "1", note = "网点状态")
    protected Integer state;

    @Column(name = "update_date", autoUpdateTime = true)
    protected Date updateDate;

    @Column(name = "create_date")
    protected Date createDate;

    @Join(fromField = "user_id")
    protected User user;

    private Long userCount;
    private Long deviceCount;
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTypeCodes() {
        return typeCodes;
    }

    public void setTypeCodes(String typeCodes) {
        this.typeCodes = typeCodes;
    }

    public String getTypeNames() {
        return typeNames;
    }

    public void setTypeNames(String typeNames) {
        this.typeNames = typeNames;
    }

    public String getThumbnailImg() {
        return thumbnailImg;
    }

    public void setThumbnailImg(String thumbnailImg) {
        this.thumbnailImg = thumbnailImg;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCityArea() {
        return cityArea;
    }

    public void setCityArea(String cityArea) {
        this.cityArea = cityArea;
    }

    public String getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getRouteInfo() {
        return routeInfo;
    }

    public void setRouteInfo(String routeInfo) {
        this.routeInfo = routeInfo;
    }

    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

    public Integer getOpenTime() {
        return openTime;
    }

    public void setOpenTime(Integer openTime) {
        this.openTime = openTime;
    }

    public Integer getCloseTime() {
        return closeTime;
    }

    public void setCloseTime(Integer closeTime) {
        this.closeTime = closeTime;
    }

    public String getContactPhone() {
        return contactPhone;
    }

    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone;
    }

	public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

	public Long getUserCount() {
		return userCount;
	}

	public void setUserCount(Long userCount) {
		this.userCount = userCount;
	}

	public Long getDeviceCount() {
		return deviceCount;
	}

	public void setDeviceCount(Long deviceCount) {
		this.deviceCount = deviceCount;
	}

	public String getAreaName() {
        return this.province + "-" + this.city + "-" + this.cityArea;
    }

    public String getStateName() {
        return PlacePhysicalStoreEnum.State.note(this.state);
    }

    public String getFullAddress() {
        String temp = this.province + "-" + this.city + "-" + this.cityArea;
        if (StringTools.isNotBlank(this.address)) {
            return temp + this.address;
        } else {
            return temp;
        }
    }

    public String getBusinessTimeStr(){
        if(this.getOpenTime() != null && this.getCloseTime() != null){
            String businessTimeStr = DateTools.changeHHmm(this.getOpenTime()) + " - "
                    + DateTools.changeHHmm(this.getCloseTime());
            return businessTimeStr;
        }
        return null;
    }
}
